package com.atguigu.wordcount.myinputformat;

import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.InputSplit;
import org.apache.hadoop.mapreduce.JobContext;
import org.apache.hadoop.mapreduce.RecordReader;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;

import java.io.IOException;

/**
 * @ClassName MyInputFormat
 * @DeScription MyInputFormat
 * @Author 剧情再美终是戏
 * @Date 2019/11/18 13:08
 * @Version 1.0
 **/
public class MyInputFormat extends FileInputFormat<Text, BytesWritable>{


    public RecordReader<Text, BytesWritable> createRecordReader(InputSplit inputSplit, TaskAttemptContext taskAttemptContext) throws IOException, InterruptedException {
        return new MyRecordReader();
    }

    // 重写这个方法，将小文件设置为不可切分
    @Override
    protected boolean isSplitable(JobContext context, Path filename) {
        return false;
    }
}
